﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HtmlExtractor.Processor
{
    public class ProcessorFactory
    {
        /// <summary>
        /// 根据名称反射创建Processor
        /// </summary>
        /// <param name="processorName">自定义的Processor必须是程序集限定名</param>
        /// <returns></returns>
        public static IProcessor CreateProcessor(string processorName)
        {
            if (processorName == "PreProcessor")
                return new PreProcessor();
            else if (processorName == "PostProcessor")
                return new PostProcessor();
            else if (processorName == "AbsoluteUriProcessor")
                return new AbsoluteUriProcessor();
            else if (processorName == "RemoveHtmlTagProcessor")
            {
                return new RemoveHtmlTagProcessor();
            }
            else if (processorName == "EntityProcessor")
            {
                return new EntityProcessor();
            }
            else
            {
                return (IProcessor)ReflectorHelper.CreateInstance(processorName);
            }
        }
    }
}
